import 'dart:convert';
import 'package:dio/dio.dart';
import 'package:flutter_fronter_service/model/address_entity.dart';
import '../config/dioConfig.dart';

Future<Map> getAddressesApi() async {
  var res = await HttpManager.getInstance().get(
    "/address/getAll",
    option: Options(responseType: ResponseType.plain),
  );
  return jsonDecode(res.toString());
}

Future<Map> saveAddressApi(AddressEntity addressEntity) async {
  var res = await HttpManager.getInstance().request(
      method:  "post",
      "/address/save",
      params: addressEntity.toJson()
  );
  return jsonDecode(res.toString());
}

Future<Map> getByIdApi(id) async {
  var res = await HttpManager.getInstance().get(
    "/address/getById/${id}",
    option: Options(responseType: ResponseType.plain),
  );
  return jsonDecode(res.toString());
}

Future<Map> deleteByIdApi(id) async {
  var res = await HttpManager.getInstance().get(
    "/address/deleteById/${id}",
    option: Options(responseType: ResponseType.plain),
  );
  return jsonDecode(res.toString());
}